{% extends 'base.html' %}

{% load humanize static %}

{% block title %}
    {{ board.name }} - {{ block.super }}
{% endblock %}

{% block stylesheet %}
    <link rel="stylesheet" href="{% static 'css/board.css' %}">
{% endblock %}

{% block breadcrumb %}
    <li class="breadcrumb-item"><a href="{% url 'home' %}">讨论</a></li>
    <li class="breadcrumb-item active">{{ board.name }}</li>
{% endblock %}

{% block content %}
    <div class="mb-4">
        <a href="{% url 'new_topic' board.pk %}" class="btn btn-primary">新的讨论</a>
    </div>

    <table class="table table-striped mb-4">
        <thead class="thead-inverse">
            <tr>
                <th>讨论</th>
                <th>发起者</th>
                <th>回复数</th>
                <th>查看数</th>
                <th>最新更新</th>
            </tr>
        </thead>
        <tbody>
            {% for topic in topics %}
                {% url 'topic_posts' board.pk topic.pk as topic_url %}
                <tr>
                    <td>
                        <p class="mb-0">
                            <a href="{{ topic_url }}">{{ topic.subject }}</a>
                        </p>
                        <small class="text-muted">
                            页数：
                            {% for i in topic.get_page_range %}
                                <a href="{{ topic_url }}?page={{ i }}">{{ i }}</a>
                            {% endfor %}
                            {% if topic.has_many_pages %}
                            ...<a href="{{ topic_url }}?page={{ topic.get_page_count }}">最后一页</a>
                            {% endif %}
                        </small>
                    </td>
                    <td>{{ topic.starter.username }}</td>
                    <td>{{ topic.replies }}</td>
                    <td>{{ topic.views }}</td>
                    <td>{{ topic.last_updated|naturaltime }}</td>
                </tr>
            {% endfor %}
        </tbody>
    </table>

    {% include 'includes/pagination.html' %}

{% endblock %}
